/**
 * Copyright (C) 2021 - 2031 O-Cubes Co., Ltd.
 */

/****************************************************************
 *  @file    pwm_test.c
 *  @brief   PWM testcase source file
 *  @version v1.0
 *  @date    03. Apr. 2023
 ****************************************************************/

#include "printf.h"
#include "hal_api.h"
#include "pwm.h"

int32_t test_pwm(void)
{
	uint32_t pwm_id;

	printf("\r\n[PWM]: TEST START\r\n");

	for (pwm_id = PWM_0; pwm_id <= PWM_1; pwm_id++)
	{
		printf("[PWM%lu]: Start PWM Output, Duty_cycle 0%%\r\n", pwm_id);
		Hal_Pwm_Start(pwm_id, 0, 1000);
		Hal_Cnt_DelayMs(3000);
	}
	

	for (pwm_id = PWM_0; pwm_id <= PWM_1; pwm_id++)
	{
		printf("[PWM%lu]: Start PWM Output, Duty_cycle 25%%, freq is 2k\r\n", pwm_id);
		Hal_Pwm_Start(pwm_id, 25, 2000);
		Hal_Cnt_DelayMs(3000);
	}
	
	for (pwm_id = PWM_0; pwm_id <= PWM_1; pwm_id++)
	{
		printf("[PWM%lu]: Start PWM Output, Duty_cycle 50%%, freq is 3k\r\n", pwm_id);
		Hal_Pwm_Start(pwm_id, 50, 3000);
		Hal_Cnt_DelayMs(3000);
	}

	for (pwm_id = PWM_0; pwm_id <= PWM_1; pwm_id++)
	{
		printf("[PWM%lu]: Start PWM Output, Duty_cycle 75%%, freq is 4k\r\n", pwm_id);
		Hal_Pwm_Start(pwm_id, 75, 4000);
		Hal_Cnt_DelayMs(3000);
	}

	for (pwm_id = PWM_0; pwm_id <= PWM_1; pwm_id++)
	{
		printf("[PWM%lu]: Start PWM Output, Duty_cycle 100%%\r\n", pwm_id);
		Hal_Pwm_Start(pwm_id, 100, 5000);
		Hal_Cnt_DelayMs(3000);
	}

	printf("[PWM]: TEST END\r\n");

	return 0;
}
